package smu.KYBank.test;

import smu.KYBank.KYBjoin;
import android.test.ActivityInstrumentationTestCase2;
import android.test.TouchUtils;
import android.view.KeyEvent;
import android.widget.EditText;

public class KYBjoinTest2 extends ActivityInstrumentationTestCase2<KYBjoin> {
	private KYBjoin mActivity;
	private EditText et_id, et_pw1, et_pw2, et_name, et_reginum1, et_reginum2,
	et_phone1, et_phone2, et_phone3, et_addr;
	
	public KYBjoinTest2() {
		super("smu.KYBank", KYBjoin.class);
	}
		
	protected void setUp() throws Exception {
		super.setUp();
		
		mActivity = this.getActivity();

		et_id = (EditText) mActivity.findViewById(smu.KYBank.R.id.j_id);
		et_pw1 = (EditText) mActivity.findViewById(smu.KYBank.R.id.j_pw1);
		et_pw2 = (EditText) mActivity.findViewById(smu.KYBank.R.id.j_pw2);
		et_name = (EditText) mActivity.findViewById(smu.KYBank.R.id.j_name);
		et_reginum1 = (EditText) mActivity.findViewById(smu.KYBank.R.id.j_reginum1);
		et_reginum2 = (EditText) mActivity.findViewById(smu.KYBank.R.id.j_reginum2);
		et_phone1 = (EditText) mActivity.findViewById(smu.KYBank.R.id.j_phone1);
		et_phone2 = (EditText) mActivity.findViewById(smu.KYBank.R.id.j_phone2);
		et_phone3 = (EditText) mActivity.findViewById(smu.KYBank.R.id.j_phone3);
		et_addr = (EditText) mActivity.findViewById(smu.KYBank.R.id.j_addr);
	}
	
	// case 2 : pw is not correct. -> return false.
	public void testValidationCheck() {
		TouchUtils.tapView(this, et_addr);
		sendKeys(KeyEvent.KEYCODE_K, KeyEvent.KEYCODE_O, KeyEvent.KEYCODE_R, KeyEvent.KEYCODE_E, KeyEvent.KEYCODE_A);
		TouchUtils.tapView(this, et_id);
		sendKeys(KeyEvent.KEYCODE_L, KeyEvent.KEYCODE_U, KeyEvent.KEYCODE_R, KeyEvent.KEYCODE_I);
		TouchUtils.tapView(this, et_pw1);
		sendKeys(KeyEvent.KEYCODE_1, KeyEvent.KEYCODE_2, KeyEvent.KEYCODE_3, KeyEvent.KEYCODE_4);
		TouchUtils.tapView(this, et_pw2);
		sendKeys(KeyEvent.KEYCODE_1, KeyEvent.KEYCODE_2, KeyEvent.KEYCODE_3);
		TouchUtils.tapView(this, et_name);
		sendKeys(KeyEvent.KEYCODE_J, KeyEvent.KEYCODE_I, KeyEvent.KEYCODE_N, KeyEvent.KEYCODE_SPACE, KeyEvent.KEYCODE_L, KeyEvent.KEYCODE_E, KeyEvent.KEYCODE_E);
		TouchUtils.tapView(this, et_reginum1);
		sendKeys(KeyEvent.KEYCODE_8, KeyEvent.KEYCODE_9, KeyEvent.KEYCODE_0, KeyEvent.KEYCODE_1, KeyEvent.KEYCODE_3, KeyEvent.KEYCODE_0);
		TouchUtils.tapView(this, et_reginum2);
		sendKeys(KeyEvent.KEYCODE_1, KeyEvent.KEYCODE_2, KeyEvent.KEYCODE_3, KeyEvent.KEYCODE_4, KeyEvent.KEYCODE_3, KeyEvent.KEYCODE_0, KeyEvent.KEYCODE_7);
		TouchUtils.tapView(this, et_phone1);
		sendKeys(KeyEvent.KEYCODE_0, KeyEvent.KEYCODE_1, KeyEvent.KEYCODE_0);
		TouchUtils.tapView(this, et_phone2);
		sendKeys(KeyEvent.KEYCODE_7, KeyEvent.KEYCODE_9, KeyEvent.KEYCODE_0, KeyEvent.KEYCODE_8);
		TouchUtils.tapView(this, et_phone3);
		sendKeys(KeyEvent.KEYCODE_1, KeyEvent.KEYCODE_9, KeyEvent.KEYCODE_0, KeyEvent.KEYCODE_8);

		assertFalse(mActivity.validationCheck());
	}


}
